# cmake needs this line
cmake_minimum_required(VERSION 2.8)

#project (TEST):指定项目名称为TEST
project(common_lib)

set (COMMON_VERSION 0.1)

#-pthread 工程引用了pthrea.h
#-lrt     
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb -DDEBUG -lpthread -lrt")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall -lpthread -lrt")

#lib out pwd
set(LIBRARY_OUTPUT_PATH  ${PROJECT_BINARY_DIR}/../lib)

#aux_source_directory(<dir> <variable>):将当前目录中的源文件名称赋值给变量 DIR_SRCS
aux_source_directory(${PROJECT_SOURCE_DIR}/common/middle                    DIR_SRC)
aux_source_directory(${PROJECT_SOURCE_DIR}/common/tools                     DIR_SRC)
aux_source_directory(${PROJECT_SOURCE_DIR}/common/middle/md_mqtt_paho/api   DIR_SRC)
aux_source_directory(${PROJECT_SOURCE_DIR}/common/middle/md_mqtt_paho/src   DIR_SRC)


#include_directories：指定头文件的搜索路径，相当于指定gcc的-I参数
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/common/tools)
include_directories(${PROJECT_SOURCE_DIR}/common/middle)
include_directories(${PROJECT_SOURCE_DIR}/common/middle/md_mqtt_paho/api)
include_directories(${PROJECT_SOURCE_DIR}/common/middle/md_mqtt_paho/src)

# 打印cmake源文件目录地址
message(${DIR_SRC})

#link_directories：动态链接库或静态链接库的搜索路径，相当于gcc的-L参数
#link_directories(${PROJECT_SOURCE_DIR}/lib)

#add_executable：编译可执行程序
#add_executable(main ${DIR_SRC})

#add_library 生成静态库 STATIC   /  SHARED 
add_library(common STATIC ${DIR_SRC})


#target_link_libraries：添加链接库,相同于指定-l参数   编译生成库时，把需要连接的第三方库带上，应用那边也要注意调用
target_link_libraries(common LINK_PRIVATE -lpthread -luuid)







